/*
 * @Author: yangzonglong
 * @Date: 2021-03-10 14:12:17
 * @version: v1.0.0
 * @Descripttion: 根据controlid 获取控件外层div 
 * @LastEditors: yangzonglong
 * @LastEditTime: 2021-03-25 15:07:17
 * @Auditor: 
 */
import { useEffect } from 'react'

/**
 * 根据控件ID获取控件最外层DOM对象
 * @param {string} [controlid] 控件ID
 * @param {Function} [domComplete] 成功获取dom后执行的回调
 */
const useQueryControlWrap = (controlid?: string, formName?: any, domComplete?: Function) => {

  useEffect(() => {
    if(!controlid) return;
    const dom = document.querySelector(`[data-controlid=${controlid}]`);
    if(dom && domComplete) domComplete(dom)
  }, [controlid, domComplete, formName])

}

export default useQueryControlWrap;